#pragma once

#include "outline.h"
#include "typedefs.h"
#include <iostream>

namespace outline {

struct circle {
	point<float> center;
	float radius;
	junc_type type;
};
typedef std::vector<circle> circle_vector;

inline std::ostream & operator << (std::ostream & out, circle const & c) { 
	return out << c.center.x << '\t' << c.center.y << '\t' << c.radius << '\t' << (int)c.type << '\n';
}

inline std::istream & operator >> (std::istream & in, circle & c) { 
	return in >> c.center.x >> c.center.y >> c.radius >> (int&)c.type;
}

struct pin : circle {
	outline::index_vector_type indeces; //sorted
	void swap(pin & a) {
		std::swap(center, a.center);
		std::swap(radius, a.radius);
		indeces.swap(a.indeces);
		std::swap(type, a.type);
	}
};
typedef std::vector<pin> pin_vector;

///throws exception if addition was not successful
template <typename T>
void add_pin(pin_vector & pins, std::vector< point<T> > const & polyline, 
	point<float> const & center, float radius, junc_type type);

template <typename T>
inline void add_pin(pin_vector & pins, std::vector< point<T> > const & polyline, 
					circle const & c) 
{
	add_pin(pins, polyline, c.center, c.radius, c.type);
}

///overlapped with circle (center, radius)
void remove_overlapped_pins(pin_vector & pins, 
	point<float> const & center, float radius);

} //namespace outline

namespace std {
	inline void swap(outline::pin & lhs, outline::pin & rhs)
		{ lhs.swap(rhs); }
};
